/* 
 * Modbus app for RTU.
 * Copyright (c) 2012  apleilx
 * All rights reserved.
 * no limite
 */

/* ----------------------- Platform includes --------------------------------*/
#define _MBAPP_MODULE_
#include "mbapp.h"
#include "osObjects.h"                                          // RTOS object definitions

uint16_t DataRecevie[32];

uint8_t mbTestErrCnt = 0;
uint8_t mbTestOkCnt = 0;

void mbTestCallBack(uint8_t CmdSite, uint8_t ErrSt);

/*****************************************************************************//*!
* @brief   	Slave device handle.
*               
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/    
void mbTask(void const *argument)
{
    uint32_t MbCnt;
    
    mbyInit(MB_RTU_SLAVE, 9600, MB_PAR_EVEN);
    mbyObj.SlaveId=2;
    
    RegHolding[0].uVal = 1000;
    RegHolding[1].uVal = 3000;
    
    RegHolding[2].uVal = 600;
    RegHolding[3].uVal = 240;
    RegHolding[4].uVal = 180;
    RegHolding[5].uVal = 75;
    RegHolding[6].uVal = 180;
    RegHolding[7].uVal = 0;
    RegHolding[8].uVal = 0;
    RegHolding[9].uVal = 60;
    
    for(;;){
        MbCnt++;
        
        if(0==(MbCnt%80)){
            RegHolding[0].uVal++;
        }
        
        osDelay(10);
        mbSlavePoll(&mbyObj);

    }
}


